package cn.chainco.cts.idaoImpl;

import java.util.List;

import cn.chainco.cts.idao.IFeeDao;
import cn.chainco.cts.jdo.Company;
import cn.chainco.cts.jdo.Fee;


public class FeeDaoImpl extends GenericHibernateDaoImpl<Fee, Long> implements IFeeDao{

	/**
	 * 费用
	 */
	@SuppressWarnings("unchecked")
	public List<Fee> findFeeByCompany(Company company , Integer status){
		String sql = " select * from cts_fee where 1=1 and companyId=" +company.getId();
		if(status!=null){
			sql += " and status="+status;
		}
		
		List<Fee> itemlist = this.getSession().createSQLQuery(sql).addEntity(Fee.class).list();
		return itemlist;
	}
	
	/**
	 * 费用
	 */
	@SuppressWarnings("unchecked")
	public List<Fee> findFeeByCompany(Company company , String name , String status , String optype , String opval){
		String sql = " select * from cts_fee where 1=1 and companyId=" +company.getId();
		
		if(name!=null && !name.trim().equals("")){
			sql += " and name_zh like '%"+name+"%' or name_en like '%"+name+"%'";
		}
		
		if(status!=null && !status.trim().equals("")){
			sql += " and status="+status;
		}
		
		List<Fee> itemlist = this.getSession().createSQLQuery(sql).addEntity(Fee.class).list();
		return itemlist;
	}
	
	/**
	 * 费用
	 */
	@SuppressWarnings("unchecked")
	public List<Fee> findFeeById(String idAry){
		String sql = " select * from cts_fee where 1=1 and id in ("+idAry+")";
		List<Fee> itemlist = this.getSession().createSQLQuery(sql).addEntity(Fee.class).list();
		return itemlist;
	}
}
